import { changeServiceEmp } from '@/api/order'
import { ref } from 'vue'
import { UpdateCustomerServiceFormReturn } from '../updateCustomerServiceFormTypes'

const useCustomerServiceForm = () => {
  const submitLoading = ref(false)
  const form = ref({
    empId: '',
    remark: '',
  })

  const submit = async (orderId: string) => {
    submitLoading.value = true
    const res = await changeServiceEmp(Object.assign(form.value, { workId: orderId }))
    submitLoading.value = false
    return res.data as UpdateCustomerServiceFormReturn
  }

  return {
    form,
    submitLoading,
    submit,
  }
}

export default useCustomerServiceForm
